package com.itheima.arrlist;

import com.itheima.object1.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListDemo04 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student student1 = studentTest();
        Student student2 = studentTest();
        Student student3 = studentTest();
        list.add(student1);
        list.add(student2);
        list.add(student3);

        for (int i = 0; i < list.size(); i++) {
            Student getStudent = list.get(i);
            System.out.println(getStudent.getName() + "," + getStudent.getAge());
        }

    }

    public static Student studentTest() {

        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        String age = sc.nextLine();
        Student student = new Student(name, age);
        return student;

    }
}
